<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.ccut.edu.cn/saturn" prefix="saturn"%>
<%@page import="java.util.*"%>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>templete jsp</title><%@ include
	file="/jsp/include/header/meta.jsp"%><%@ include
	file="/jsp/include/header/javascript.jsp"%>
<%@ include file="/jsp/include/header/stylesheettag.jsp"%>
</head>
<body onload="">
<script type="text/javascript">
function doUpdate(){
	var keys = document.getElementsByName("key");
	var values = document.getElementsByName("value");
	var errorInfos = "";
	for(var i = 0 ; i < keys.length; i++){
		errorInfos += keys[i].value + ":" + values[i].value ;
		if(i < (keys.length - 1))
			errorInfos += ",";
	}
	updateForm.errorMap.value = errorInfos;
	updateForm.submit();
}
</script>
<%
	List list = new ArrayList();

	Map map1 = new HashMap();
	map1.put("key", "空");
	map1.put("value", "空");

	Map warn = new HashMap();
	warn.put("key", "validateType_warn");
	warn.put("value", "validateType_warn");

	Map error = new HashMap();
	error.put("key", "validateType_error");
	error.put("value", "validateType_error");

	list.add(map1);
	list.add(warn);
	list.add(error);
%>
<saturn:formBeans title="验证信息" name="updateForm"
	action="/server/edu.ccut.saturn.manager.bundles.impl::/componentModule/action/UpdateParamValidateInfoAction.action"
	method="post">

	<input name="errorMap" type="hidden" value=""/>
	<saturn:formBean name="" type="label" label="验证FullKey:"
		value="${validateInfoFullkey }"></saturn:formBean>
	<saturn:formBeanLine />

	<saturn:formBean name="" type="label" label="验证名称:"
		value="${validateName }"></saturn:formBean>
	<saturn:formBeanLine />

	<saturn:formBean name="" type="label" label="描述信息:"
		value="${descreption}"></saturn:formBean>
	<saturn:formBeanLine />

	<saturn:formBeanSelect textKey="value" valueKey="key"
		defaultValue="${validateType}" label="验证错误类型:" name="validateType"
		value="<%=list %>" />
	<saturn:formBeanLine />

	<td class="saturn-style-td-label">验证错误信息：</td>
	<td>
	<table style="background: #dddddd;">

		<%
					Map<String, String> map = (Map<String, String>) request
					.getAttribute("errorMap");
			if (map != null) {

				Set<String> set = map.keySet();

				Iterator<String> errorMapKeyIterator = set.iterator();

				while (errorMapKeyIterator.hasNext()) {
					String key = errorMapKeyIterator.next();
					String value = map.get(key);
		%>
		<tr>
			<td>key:</td>
			<td><input type="text" name="key" value="<%=key%>"
				style="border: none;" readonly="readonly" /> &nbsp;&nbsp;&nbsp;</td>
			<td>value:</td>
			<td><input type="text" name="value" value="<%=value%>" /></td>
		</tr>
		<%
			}
			}
		%>
	</table>
	</td>
	<input type="hidden" name="nodeId" value="${nodeId }">
	<input type="hidden" name="fullKey" value="${fullKey }">
	<input type="hidden" name="paramId" value="${paramId }">
	<input type="hidden" name="validateInfoFullkey"
		value="${validateInfoFullkey }">
	<input type="hidden" name="validateName" value="${validateName }">
	<input type="hidden" name="descreption" value="${descreption}">
	<saturn:formBeanLine />

	<!--           参数列表                -->
	<%
				List<String> arglistOld = (List<String>) request
				.getAttribute("argList");
		if (arglistOld != null) {
			for (int i = 0; i < arglistOld.size(); i++) {
	%>
	<saturn:formBean name="argList" type="text" label="参数<%=(i + 1)%>:"
		value="<%=arglistOld.get(i)%>"></saturn:formBean>
	<saturn:formBeanLine />
	<%
		}
		}
	%>

	<!--            验证事件列表                -->
	<td class="saturn-style-td-label">事件类型:</td>
	<td class="saturn-style-td-tag">
	<table id="eventtable" style="background: white;">

			<%
 	List<String> eventInitList = new ArrayList<String>();
 	eventInitList.add(0, "onblur");
 	eventInitList.add(1, "onchange");
 	eventInitList.add(2, "onclick");
 	eventInitList.add(3, "ondblclick");
 	eventInitList.add(4, "onfocus");

 	eventInitList.add(5, "onhelp");
 	eventInitList.add(6, "onkeydown");
 	eventInitList.add(7, "onkeypress");
 	eventInitList.add(8, "onkeyup");
 	eventInitList.add(9, "onmousedown");

 	eventInitList.add(10, "onmounsemove");
 	eventInitList.add(11, "onmouseout");
 	eventInitList.add(12, "onmouseover");
 	eventInitList.add(13, "onmouseup");
 	eventInitList.add(14, "onselect");

 List<String> eventListOld = (List<String>) request.getAttribute("eventList");
 	
 	if (eventListOld != null) {
 		for (int i = 0; i < eventInitList.size(); i++) {
 			//判断eventlist中是否有当前值
 			boolean flag = false;
 			for (int j = 0; j < eventListOld.size(); j++) {
		 		if (eventListOld.get(j).equals(eventInitList.get(i))) {
		 			flag = true;
		 		}
		 		if (i % 5 == 0) {
		 %> <tr> <%
				}
 			}
				if (flag == true) {
			%><td> <input name="eventList" type="checkbox"
				value="<%=eventInitList.get(i) %>" checked="checked" /><%=eventInitList.get(i)%></td>
			<%
			    } else {
			%> <td><input name="eventList" type="checkbox"
				value="<%=eventInitList.get(i) %>" /><%=eventInitList.get(i)%> </td><%
 		        }
						if (i % 5 == 4) {
							%></tr><%
						}
 						
						
 		}
 	} else {

 		for (int i = 0; i < eventInitList.size(); i++) {
 			if (i % 5 == 0) {
 %> <tr>
			<%
			}
			%> <td><input name="eventList" type="checkbox"
				value="<%=eventInitList.get(i) %>" /><%=eventInitList.get(i)%>&nbsp;</td>
			<%
			if (i % 5 == 4) {
				%>
				</tr>
				<% 
				}
 		
 			
 		}
 		}
			%>
	</table>
	</td>
	<saturn:formBeanLine />

	<saturn:formActions>
		<saturn:input name="" value="ok" onclick="doUpdate()" type="button" />
	</saturn:formActions>
</saturn:formBeans>
</body>
</html>